package pers.corvey.studyjava.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import pers.corvey.studyjava.util.ToStringUtils;


@Entity
public class User {

    public static final int ACCOUNT_MIN_LEN = 6;
    public static final int ACCOUNT_MAX_LEN = 20;
    public static final int PASSWORD_MIN_LEN = 6;
    public static final int PASSWORD_MAX_LEN = 20;
    public static final int NAME_MIN_LEN = 2;
    public static final int NAME_MAX_LEN = 24;
    
    private String id;
    private String account;
    private String password;
    private String gender;
    private String name;
    private Date gmtCreate;
    private Date gmtModified;
    
    public User() {}

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Column(unique=true)
    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name="gmt_create", updatable=false)
    @Temporal(TemporalType.TIMESTAMP)
    public Date getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(Date gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    @Column(name="gmt_modified")
    @Temporal(TemporalType.TIMESTAMP)
    public Date getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(Date gmtModified) {
        this.gmtModified = gmtModified;
    }
    
    @Override
    public String toString() {
        return ToStringUtils.objectToString(this);
    }

}
